clear;
u = [3 -7; -1 4];
v = 1/2 * [1 -1; -1 1];
w = 1/2 * [-1 1; -1 1];

norm_u = norm(u, 'fro');
norm_v = norm(v, 'fro');
norm_w = norm(w, 'fro');

scalar_uv = dot(u(:), v(:));
scalar_uw = dot(u(:), w(:));
scalar_vw = dot(v(:), w(:));

orthonormality = isequal(round(transpose([v(:), w(:)]) * [v(:), w(:)]), eye(2));

% 
x1 = scalar_uv;
x2 = scalar_uw;
proj = [v(:),w(:)] * [x1;x2];

% 将重构的向量重新恢复为原始形状
proj = reshape(proj, size(u));

% 计算误差
difference = u - proj;    % Calculate the element-wise difference
error = sum(sum(difference.^2));    % Calculate the squared Euclidean distance

error